//
//  UserDefaultsHelper.m
//  Feeder
//
//  Created by Diego Acosta on 8/15/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "UserDefaultsHelper.h"

#define kUserDefsUsernameKey @"username"
#define kUserDefsAuthKey @"auth"


@implementation UserDefaultsHelper

#pragma mark Class methods

+ (void)registerDefaults {

	NSUserDefaults * userdefs = [NSUserDefaults standardUserDefaults];
	
	NSArray * keys = [NSArray arrayWithObjects:kUserDefsUsernameKey, kUserDefsAuthKey, nil];
	NSArray * values = [NSArray arrayWithObjects:@"", @"", nil];
	
    NSDictionary * dict = [NSDictionary dictionaryWithObjects:values
													  forKeys:keys];
	
	[userdefs registerDefaults:dict];
}

+ (void)setUsername:(NSString *)username {
	
	NSUserDefaults * userdefs = [NSUserDefaults standardUserDefaults];
	
	[userdefs setObject:username forKey:kUserDefsUsernameKey];
	[userdefs synchronize];
}

+ (NSString *)username {

	NSUserDefaults * userdefs = [NSUserDefaults standardUserDefaults];
	
	return [userdefs objectForKey:kUserDefsUsernameKey];
}

+ (void)setAuth:(NSString *)auth {

	NSUserDefaults * userdefs = [NSUserDefaults standardUserDefaults];
	
	[userdefs setObject:auth forKey:kUserDefsAuthKey];
	[userdefs synchronize];
}

+ (NSString *)auth {

	NSUserDefaults * userdefs = [NSUserDefaults standardUserDefaults];
	
	return [userdefs objectForKey:kUserDefsAuthKey];
}

@end
